<template>
    <ul class="content">
        <li     v-for="(item, index) in essaysArr" :key="item.wid"
                class="content_li top"
                :class="{'global_font':$store.state.nowTime==='moon'}">
            <Encrypt :encrypt="item" :index="index"></Encrypt>
        </li>
    </ul>

</template>

<script>
import Encrypt from "@/components/home/Encrypt.vue";
import api from "@/api";
import UserArticleContent from "@/components/home/UserArticleContent.vue";

export default {
    name: "BodyContent",
    components: {
        UserArticleContent,
        Encrypt,
    },
    props: {
        essays: Object,
    },
    data() {
        return {
            supplement: 1100,
            index: 1,
            essaysArr: [],
            moon: false

        }
    },
    mounted() {
        if (window.localStorage.getItem("nowTime") === 'moon')
            this.moon = true;

        window.addEventListener('scroll', this.handleScrollx, true);
        api.selectLimit(this.index).then((res) => {
            this.essaysArr = res.data.data;
        });

    },


    methods: {
        handleScrollx() {
            if (window.pageYOffset >= this.supplement) {
                this.index++;
                api.selectLimit(this.index).then((res) => {
                    for (let i = 0; i < res.data.data.length; i++)
                        this.essaysArr.push(res.data.data[i]);
                });
                this.supplement += 1200;
            }

        },
    },
}
</script>

<style scoped>
.top {
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.6);
}

a {
    color: #646060;
    transition: all .1s;
    font-size: 1.3rem;
}

a:hover {
    color: #3586f1;
}

.content {
    list-style: none;
    min-width: 500px;
    min-height: 28vh;
    border-radius: 5px;
    width: 45vw;
    margin: auto;
    color: #8f8c8c;
}

.content li {
    width: 100%;
    transition: all .3s;
    height: 13vh;
    min-height: 200px;
    min-width: 400px;
    overflow: hidden;
    border-radius: 5px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    margin-bottom: 30px;
}

.content li:hover {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    opacity: .9;
}

.content li:hover {
    transform: translateY(-0.5rem);
}

img {
    width: 1rem;
    margin-left: 10px;
}

.information_right img {
    margin-right: 3px;
}


@media (min-width: 0px) and (max-width: 600px) {
    .content {
        min-width: 370px;
    }
    .content li {
        min-width: 300px;
        min-height: 190px;
    }
}

@media (min-height: 0px) and (max-height: 900px) {
    .content li {
        margin-top: 20px;

    }
}
</style>